//
//  WPYBBaseViewController.m
//  wobingwoyi
//
//  Created by WGP on 2016/12/16.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "WPYBBaseViewController.h"

@interface WPYBBaseViewController ()

@property(nonatomic,strong)UIView *statusBarView;

@end

@implementation WPYBBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self statusBarView];
    [self navBarView];
}

#pragma mark - 懒加载
-(UIView *)statusBarView
{
    if (_statusBarView == nil)
    {
        _statusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 20)];
        _statusBarView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:_statusBarView];
        
    }
    return _statusBarView;
}

-(UIView *)navBarView
{
    if (_navBarView == nil)
    {
        _navBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH, 44)];
        _navBarView.backgroundColor = [UIColor whiteColor];
        [self.view addSubview:_navBarView];
        
        UIButton  *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [backBtn setBackgroundImage:[UIImage imageNamed:@"back_normal"] forState:UIControlStateNormal];
        [backBtn setBackgroundImage:[UIImage imageNamed:@"back_highlight"] forState:UIControlStateHighlighted];
        [backBtn sizeToFit];
        [backBtn addTarget:self action:@selector(backBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
        [_navBarView addSubview:backBtn];
        
        [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.navBarView);
            make.left.equalTo(self.navBarView).offset(10);
        }];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.textColor = GLobalFontColor;
        self.titleLabel.font = [UIFont systemFontOfSize:18];
        self.titleLabel.text = @"我的医币";
        [_navBarView addSubview:self.titleLabel];
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self.navBarView);
        }];
        
        self.rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.rightBtn sizeToFit];
        [self.rightBtn setTitleColor:GLobalFontColor forState:UIControlStateNormal];
        [self.rightBtn setTitleColor:GloballightFontColor forState:UIControlStateHighlighted];
        self.rightBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        [self.rightBtn addTarget:self action:@selector(rightBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
        [_navBarView addSubview:self.rightBtn];
        
        [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.navBarView);
            make.right.equalTo(self.navBarView).offset(-10);
        }];
        
        UIImageView *lineView = [UIImageView lineImageView];
        lineView.backgroundColor = RGB_SAME(203);
        [_navBarView addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(_navBarView);
            make.height.mas_equalTo(0.5);
        }];
    }
    return  _navBarView;
}

-(void)backBtnDidClick
{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)rightBtnDidClick
{
    //右边按钮点击
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
